<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<script src="../js/easyui-1.3.5/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var rootName = ajax.getRootName();

$(function() {
  //请求websocket客户端
  var url = rootName + "/api/ws/notify/list";
  $.get(url, {}, function(message) {
    var select=document.getElementsByName('topic_ws')[0];
    
    for(var i=0;i<message.length;i++){
      var option=new Option(message[i],message[i]);
      select.add(option,undefined);
    }
    
  });

  $("input[name=send_mq]").click(function() {
    var topic = $("input[name=topic_mq]").val();
    var text = $("input[name=message_mq]").val();
    var url = rootName + "/api/mq/send?message=" + text + "&topic=" + topic;
    $.get(url, {}, function(data) {
      alert(data);
    })
  });
  $("input[name=send_ws]").click(function() {
    var select = document.getElementsByName('topic_ws')[0];
    var topic=select[select.selectedIndex].value;
    
    var text = $("input[name=message_ws]").val();
    var url = rootName + "/api/ws/notify/send?message=" + text + "&topic=" + topic;
    $.get(url, {}, function(data) {
      alert(data);
    })
  });
});
</script>
</head>

<body>
<div id="id">apache-apollo测试</div>
topic:<input type="text" name="topic_mq" value="vp1"> message:<input type="text" name="message_mq" value="你好,李先生">
<input type="button" name="send_mq" value="发送">
<br />
<br />
<div id="id">websocket测试</div>
topic:<select name='topic_ws'></select> 
message:<input type="text" name="message_ws" value="你好,李先生">
<input type="button" name="send_ws" value="发送">

</body>

</html>